package com.ux.example
{
	import com.greensock.TweenMax;
	import com.greensock.easing.Back;
	
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	
	public class RectExpendTest extends Sprite
	{
		private var mc : MovieClip;
		private var mcRect : Rectangle;
		
		public function RectExpendTest()
		{
			super();
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			
			var rect : Shape = new Shape();
			rect.graphics.beginFill( 0x000000, 1 );
			rect.graphics.drawRect(0,0,100,100 );
			rect.graphics.endFill();
			
			mc = new MovieClip();
			mc.addChild( rect );
			
			
			

//			mcRect = new Rectangle( 300, 300, mc.width, mc.height );
			mc.x = 300;
			mc.y = 300;
			
			addChild( mc );
			mcRect = mc.getRect( this );
			trace(" ==> RectExpendTest RectExpendTest : " + mcRect );
			
			mc.addEventListener(MouseEvent.ROLL_OVER, onOver );
			mc.addEventListener(MouseEvent.ROLL_OUT, onOut );
		}
		
		
		private function onOver( e:MouseEvent ):void 
		{

			TweenMax.to( mc, 0.5 , {width:200, height:200, ease:Back.easeOut, onUpdate:rePosition} );
		}
		
		private function onOut( e:MouseEvent ):void 
		{

			TweenMax.to( mc, 0.5 , {width:mcRect.width, height:mcRect.height, ease:Back.easeOut, onUpdate:rePosition} );
		}
		
		private function rePosition():void
		{
//			trace(" ==> RectExpendTest rePosition : ");
			mc.x = mcRect.x - (mc.width - mcRect.width )/2;
			mc.y = mcRect.y - (mc.height - mcRect.height )/2;
		}
		
	}
}